package com.cf.studiomanage.mapper;

import com.cf.studiomanage.entity.Activity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivityMapper {

    @Insert("INSERT INTO activity(title, description, location, time, created_by) VALUES(#{title}, #{description}, #{location}, #{time}, #{createdBy})")
    int createActivity(Activity activity);

    @Update("UPDATE activity SET title=#{title}, description=#{description}, location=#{location}, time=#{time} WHERE id=#{id}")
    int updateActivity(Activity activity);

    @Delete("DELETE FROM activity WHERE id = #{id}")
    int deleteActivity(Long id);

    @Select("SELECT * FROM activity ORDER BY time DESC")
    List<Activity> getAllActivities();

    @Select("SELECT * FROM activity WHERE id = #{id}")
    Activity getById(Long id);
}
